import {request} from "@umijs/max";


export async function getDepartments(options?: { [key: string]: any }) {
  return request<{
    data: Department.DepartmentResult;
  }>('/department/searchDepartment', {
    method: 'GET',
    ...(options || {}),
  });
}

export async function updateDepartments(body: Department.DepartmentUpdateParams, options?: { [key: string]: any }) {
  return request<{
    data: API.ApiResult<any>;
  }>('/department/update', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

export async function addDepartmentMember(body: Department.DepartmentMemberParams, options?: { [key: string]: any }) {
  return request<{
    data: API.ApiResult<any>;
  }>('/department/addMember', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

export async function updateDepartmentPacket(body: Department.DepartmentUpdatePacketParams, options?: {
  [key: string]: any
}) {
  return request<{
    data: API.ApiResult<any>;
  }>('/department/updateInviteReward', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

export async function getDepartmentMembers(params: Department.GetDepartmentMemberParams, options?: {
  [key: string]: any
}) {
  const queryString = new URLSearchParams(params as any).toString();

  return request<{
    data: Department.DepartmentMemberResult;
  }>(`/department/searchMember?${queryString}`, {
    method: 'GET',
    ...(options || {}),
  });
}

export async function updateMemberDepartment(body: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<{
    data: API.ApiResult<any>;
  }>('/department/updateMemberDepartment', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

export async function updateMemberStatus(body: Department.UpdateMemberStatusParams, options?: { [key: string]: any }) {
  return request<{
    data: API.ApiResult<any>;
  }>('/department/updateMemberStatus', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
